<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { KeyValues } from '../../utils/types';
import { FormInstance, FormItemRule } from 'element-plus';

const props = defineProps<{
  row?: any
}>()

const emit = defineEmits(['close', 'submitted'])

const form = ref<KeyValues>({})

const formRef = ref<FormInstance>()


const close = () => emit('close')

const onOk = async () => {
  emit('submitted', { form: form.value })
}

onMounted(() => {
  if (props.row.row) {
    form.value = { ...props.row.row }
  }
})
</script>
<template>
  <ElDialog ref="dialogRef" title="编辑">
    <ElForm ref="formRef" label-width="6em" :model="form" >
      <ElFormItem label="常量" prop="sourceValue">
        <ElInput placeholder="请输入" v-model="form.sourceValue"></ElInput>
      </ElFormItem>
    </ElForm>
    <template #footer>
      <ElButton @click="close">取消</ElButton>
      <ElButton type="primary" @click="onOk">确定</ElButton>
    </template>
  </ElDialog>
</template>

